When executing a task that requires I/O (input/output), a conventional application framework in computer technologies generally needs to enter a pause state because of waiting for data input. For example, when a socket function monitoring port is invoked to wait to receive data sent by a remote server or monitor an input stream corresponding to a system input event, the pause state is entered, and as a result, execution of program processes cannot be continued.
To avoid a program from entering the pause state because of waiting for I/O, the conventional application framework generally executes a blocking task in a respective thread, that is, a program is executed in a multi-thread manner, and when a certain thread is blocked because of executing an I/O task, the thread can be switched to other threads by means of scheduling by an operating system, so as to ensure asynchronous execution.
However, because an overhead for the operating system to create and manage threads is large, the number of times for context switching of the operating system increases exponentially when the application framework is busy with services and creates an excessively large number of threads. But system performance is limited, thereby reducing the number of system concurrent I/O.
It is also possible to change the program logic code into an asynchronous state machine, such that each task can execute multiple states, and increase the execution throughput this way. The problem of this approach is that existing multi-thread programming logic can no longer be used, and redesigning the entire programming architecture is costly and complex.